package com.hdu.controller;

import com.hdu.domain.ServiceInstance;
import com.hdu.result.R;
import com.hdu.service.TaskService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("client")
public class ClientController {

    private final TaskService taskService;

    public ClientController(TaskService taskService) {
        this.taskService = taskService;
    }

    @PostMapping("register")
    public R register(@RequestBody Map<String, ServiceInstance> serviceInstanceMap) {
        taskService.addServiceInstance(serviceInstanceMap);
        return R.success();
    }
}
